package com.uuah.server.config.spring.parsers.specific;

import com.uuah.server.config.spring.parsers.AbstractUuahBeanDefinitionParser;
import com.uuah.server.config.spring.parsers.IUuahDefinitionParser;
import com.uuah.server.config.spring.parsers.delegate.ParentContextDefinitionParser;
import com.uuah.server.config.spring.parsers.generic.ParentDefinitionParser;

/**
 * Handle response transformers correctly
 */
public class TransformerRefDefinitionParser extends
		ParentContextDefinitionParser {

	public TransformerRefDefinitionParser() {
		super(TransformerDefinitionParser.RESPONSE_TRANSFORMERS, addAlias(
				new ParentDefinitionParser(),
				AbstractUuahBeanDefinitionParser.ATTRIBUTE_REF,
				TransformerDefinitionParser.RESPONSE_TRANSFORMER));
		otherwise(addAlias(new ParentDefinitionParser(),
				AbstractUuahBeanDefinitionParser.ATTRIBUTE_REF,
				TransformerDefinitionParser.TRANSFORMER));
	}

	private static IUuahDefinitionParser addAlias(IUuahDefinitionParser parser,
			String alias, String name) {
		parser.addAlias(alias, name);
		return parser;
	}

}